]> dgit.raspbian.org Git - gnome-shell.git/commit
keyboard: Fix deleting the previous word
authorSebastian Keller <skeller@gnome.org>
Wed, 21 Feb 2024 14:20:24 +0000 (15:20 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 29 Feb 2024 14:56:16 +0000 (14:56 +0000)
commit484a237002c9e7ea1b777470c01870437ee23cc2
tree893e5004da32df979e1e96897c83b31242b76e21
parent7552875dbc78eb52e7d3b5a9f784c175ecca585c
keyboard: Fix deleting the previous word

Since mutter@33088d59 the cursor we receive from mutter already is a
character index while the code here still treated it like a byte offset.

Further the code to detect the previous word position was treating the
cursor parameter already like a character index, while passing the
cursor that was prior to that commit a byte offset.

The function also had some unreachable and redundant code paths. The
pos < 0 case can never be reached due to the max(). Also the regex
already ensures that all whitespace is considered, so the code to remove
spaces not actually do anything except when deleting the first word in
the text, in which it would cause the first character to not get
deleted.

Also it was not handling characters with more than 2 bytes correctly. In
the presence of these JS string functions, such as search(), can not be
considered to operate on character indices anymore but rather the number
of UTF-16 byte pairs. Issues with this can be avoided by using
iterators, which unlike anything else iterate on characters, not byte
pairs and by not using the results returned by JS string functions for
anything but JS strings.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2746>
js/ui/keyboard.js